package com.nanhai.buddhist.college.module.system.dal.mysql.rolegroup;

import java.util.*;

import com.nanhai.buddhist.college.framework.common.pojo.PageResult;
import com.nanhai.buddhist.college.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.nanhai.buddhist.college.framework.mybatis.core.mapper.BaseMapperX;
import com.nanhai.buddhist.college.module.system.dal.dataobject.rolegroup.RoleGroupUserDO;
import org.apache.ibatis.annotations.Mapper;
import com.nanhai.buddhist.college.module.system.controller.admin.rolegroup.vo.*;

/**
 * 角色群组用户 Mapper
 *
 * @author xqenzo@163.com
 */
@Mapper
public interface RoleGroupUserMapper extends BaseMapperX<RoleGroupUserDO> {

    default PageResult<RoleGroupUserDO> selectPage(RoleGroupUserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<RoleGroupUserDO>()
                .eqIfPresent(RoleGroupUserDO::getSystemRoleGroupId, reqVO.getSystemRoleGroupId())
                .eqIfPresent(RoleGroupUserDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(RoleGroupUserDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(RoleGroupUserDO::getId));
    }

    default List<RoleGroupUserDO> selectList(RoleGroupUserExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<RoleGroupUserDO>()
                .eqIfPresent(RoleGroupUserDO::getSystemRoleGroupId, reqVO.getSystemRoleGroupId())
                .eqIfPresent(RoleGroupUserDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(RoleGroupUserDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(RoleGroupUserDO::getId));
    }


    default List<RoleGroupUserDO> selectByGroupId(Long groupId) {
        return selectList(new LambdaQueryWrapperX<RoleGroupUserDO>()
                .eqIfPresent(RoleGroupUserDO::getSystemRoleGroupId, groupId));
    }

}
